# 字典
#键值对形式创建
dict = {'name':'Mark','age':18,'sex':'male'}
print(dict)

print("")

#推导式创建
dict2 = {i:i**2 for i in range(5)}
print(dict2)
dict3 = {i:ord(i) for i in "abcd"}
print(dict3)

list1 = ['name','age','sex']
list2 = ['Amy',18,'false']
dict4 = {i:j for i in list1 for j in list2}
print(dict4)

print("")

# 检索字典内部信息
#通过键值进行索引
print(dict['name'])
print(dict['age'])
print(dict['sex'])

print("")

#关键字
print(dict4.keys())
for i in dict4.keys():
    print(i)

print(dict4.values())
for i in dict4.values():
    print(i)